package com.lrf.eb.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lrf.eb.model.EbNews;
import com.lrf.eb.service.EbNewsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller//web层--证
@RequestMapping("news")
public class EbNewsController {
    @Autowired
    private EbNewsService ebNewsService;
    @RequestMapping("view")
            public String listBy(Model model,int newsId,
                               @RequestParam(value = "nsize",defaultValue = "1")int nsize,
                               @RequestParam(value = "newsSize",defaultValue = "8")int newsSize){
        Page<EbNews> ebNewsPage = ebNewsService.listByNews(newsId,nsize,newsSize);

        model.addAttribute("ebNewsPage",ebNewsPage);

        return "news-view";
    }

    @RequestMapping("/detail")
    public String detail(Model model,int enId){
        EbNews ebNews =ebNewsService.detail(enId);
        model.addAttribute("ebNews",ebNews);
        return "news-view";
    }


}
